package com.etc.service.impl;

import com.etc.dao.AuthorDAO;
import com.etc.entity.Author;
import com.etc.service.AuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class AuthorServiceImpl implements AuthorService {

    @Autowired
    private AuthorDAO dao;

    @Override
    public Author getById(int authoid) {
        return dao.selectByPrimaryKey(authoid);
    }



    //支持当前事务，如果当前没有事务，就新建一个事务。这是最常见的选择
    @Transactional(propagation = Propagation.REQUIRED)
    public void test1(){

        //1
        //2
        //3
        //4
        //...
        //xx
    }

    @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.READ_COMMITTED)
    public void test2(){

        //1
        //2
        //3
        //4
        //...
        //xx
    }
}
